package com.jmars.TS.service.impl;

import com.alibaba.fastjson.JSON;
import com.jmars.TS.common.AjaxResult;
import com.jmars.TS.common.JiumiConfig;
import com.jmars.TS.entity.GetOrderPickStsRequest;
import com.jmars.TS.entity.InOrderPickSts;
import com.jmars.TS.entity.NribResult;
import com.jmars.TS.mapper.db1.WMSInOutMapper;
import com.jmars.TS.mapper.db1.WmsApiMapper;
import com.jmars.TS.model.entity.GetWmsStoreReturnListRequest;
import com.jmars.TS.model.entity.GetWmsStoreReturnListResponse;
import com.jmars.TS.service.WmsService;
import lombok.var;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.util.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @Author: whd
 * @DateTime: 2024/09/12 13:41
 * @msg:
 */
@Service
public class WmsServiceImpl implements WmsService {
    private static final Logger logger = LoggerFactory.getLogger(WmsServiceImpl.class);
//
    /** 系统基础配置 */
    @Autowired
    private JiumiConfig jiumiConfig;

    @Autowired
    WmsApiMapper wmsApiMapper;



    @Override
    //@Transactional
    public AjaxResult getWmsStoreReturnList(String pBody) {

        GetWmsStoreReturnListRequest reqParam = JSON.parseObject(pBody, GetWmsStoreReturnListRequest.class);

        // 参数
        String pVendorId = reqParam.getVendorId();
        String pArticleId = reqParam.getArticleId();

        String code = "401";
        String msg = "参数不正确";
        String body = null;

        try {

            // 判断参数条件
//            if(StringUtils.isEmpty(pVendorId) && StringUtils.isEmpty(pArticleId)){
//                return new AjaxResult(code,msg,body) ;
//            }

            // 查询数据
            List<GetWmsStoreReturnListResponse> data = wmsApiMapper.selectStoreReturnList(pVendorId,pArticleId);

            // 处理请求逻辑
            body = JSON.toJSONString(data);
            return AjaxResult.success("success",body) ;

        }
        catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }

        return new AjaxResult(code,msg,body) ;
    }


}
